package ACWing.TheNnderlyingAlgorithm.双指针;
//2816. 判断子序列（边界条件宁可多写不可省略）

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/11/25 22:50
 */
public class DetermineSubsequences {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[]arr=new int[n];
        int[]arr2=new int[m];
        for (int i = 0; i < n; i++) {
            arr[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            arr2[i]=sc.nextInt();
        }
        //题意是有序的所以双指针可以实现
        int j=0;
        for (int i = 0; i < n; i++) {
            while (j<m){
                if(arr2[j]==arr[i]){
                    break;
                }
                j++;
            }//弹出条件要注意
            if(i==n-1&&j==m){//边界条件
                System.out.println("No");
                return;
            }
            j++;//为下一次比较做准备
            if(j>m){//j所遍历的数组已经走完了而且超出了范围
                System.out.println("No");
                return;
            }

        }
        System.out.println("Yes");
    }

}
